package za.org.jcicada.genss.sensor;

import java.io.Serializable;

/**
 * Interface for defining types of sensors. Each sensor must store a handle
 * to an implementation of this interface to describe what values it may take.
 * We didn't subclass Sensor because that would have limited our options when
 * we wanted to implement aggregate sensors due to single inheritance limitation.
 * @author rcrida
 */
public interface ISensorType extends Serializable {
    
    /**
     * Check if the value is a legal instance for the sensor type.
     * @param value to be checked
     * @return true if the value is legal for the sensor type
     */
    boolean isValid(Object value);
    
    /**
     * Parse the string and extract a value object suitable for this sensor type.
     * @param string to be parsed
     * @return the object represented by the string
     */
    Object valueOf(String string);
    
    /**
     * Create a string array representation of this object. Suitable for use
     * with String[] constructor.
     * @return string representation of all args of this object
     */
    String[] toStringArray();
    
    /**
     * Try to convert the value to a double value.
     * @return double representing the value of the sensor
     */
    double doubleValueOf(Object value);

}
